<?php
require_once 'mysql.class.php';
$nombre_sesion = "GestionDVD";
$db = new MySQL();
function existPPU($ppu) {
    $retorno = false;
    $result = mysql_query("SELECT * FROM ".$prefix."bus WHERE PPU = '".$ppu."'");
    $c = mysql_num_rows($result);
    if ($c != 0)  {
        $retorno = true;
    }
    return $retorno;
}
function es_int($numero){
    if (preg_match("/^[0-9]/",$numero))
        return true;
    else
        return false;
}
function quitarFormato($variable){
    $sig[]='.';
    $sig[]=',';
    return str_replace($sig,'',$variable);
}
function toTimestamp($fecha, $hora) {
    //yyyy/mm/dd
    $hora = explode(":", $hora);
    $fecha = explode("/", $fecha);
    $tiempo = mktime($hora[0], $hora[1], $hora[2], $fecha[1], $fecha[2], $fecha[0]);
    return $tiempo;
}
function getFechaNormal($fecha) {
    $fecha = explode("-", $fecha);
    $fecha = $fecha[2].'/'.$fecha[1].'/'.$fecha[0];
    return $fecha;
}
function setFechaDB($fecha) {
    $fecha = explode("/", $fecha);
    $fecha = $fecha[2].'-'.$fecha[1].'-'.$fecha[0];
    return $fecha;
}
function mostrarPeligro($msg) {
    echo "<table width=\"301\" border=\"0\" align=\"center\"><tr><td width=\"295\"><div class=\"warning\" id= class=\"warning\">".$msg."</div></td></tr></table>";
}
function mostrarCompleto($msg) {
    //Proceso Completo con exito
    echo "<table width=\"301\" border=\"0\" align=\"center\"><tr><td width=\"295\"><div class=\"success\" id=\"success\">".$msg."</div></td></tr></table>";
}
function mostrarInfo($msg) {
    //Mostrar informacion
    echo "<table width=\"301\" border=\"0\" align=\"center\"><tr><td width=\"295\"><div class=\"info\" id=\"info\">".$msg."</div></td></tr></table>";
}
function mostrarError($msg) {
    //Error!!!!
    echo "<table width=\"301\" border=\"0\" align=\"center\"><tr><td width=\"295\"><div class=\"error\" id=\"error\">".$msg."</div></td></tr></table>";
}
function getScape($theValue, $theType = "") {
    if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
    if ($theType == null) $theType = "text";
    if(function_exists("mysql_real_escape_string"))
        $theValue = mysql_real_escape_string($theValue);
    else
        $theValue = mysql_escape_string($theValue);
    switch ($theType) {
        case "text":
              $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
              break;
        case "long":
        case "int":
              $theValue = ($theValue != "") ? intval($theValue) : "NULL";
              break;
        case "double":
              $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
              break;
        case "no":
              $theValue = ($theValue != "") ? $theDefinedValue : "NULL";
              break;
    }
    return $theValue;
}
function redirige($url) {
    header('Location: '.$url);
    echo "<script>window.location.href='".$url."';</scritp>";
    exit;
}
function isAdmin() {
    if ($_SESSION["Poder"] == 1)
        return true;
    else
        return false;
}
?>
